package com.wei.czz.common.vo.admin.menu;

import com.alibaba.excel.annotation.ExcelProperty;
import com.wei.czz.common.easyexcel.converter.CzzLongStringConverter;
import com.wei.czz.common.vo.common.UploadVo;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2024-11-25 22:28:48
 * className: MenuUploadVo
 * version: 1.0
 * description:
 */
@Getter
@Setter
public class MenuUploadVo extends UploadVo {

    /**
     * 父级菜单（序号|主键）
     */
    @NotNull(message = "父级菜单（序号|主键）不能为空")
    @ExcelProperty(value = "父级菜单（序号|主键）", converter = CzzLongStringConverter.class)
    private Long parentNo;

    /**
     * 菜单名称
     */
    @NotBlank(message = "菜单名称不能为空")
    @ExcelProperty(value = "菜单名称")
    private String name;

    /**
     * 菜单类型[0-目录 1-页面 2-按钮]
     */
    @NotBlank(message = "菜单类型不能为空")
    @ExcelProperty(value = "菜单类型")
    private String typeName;

    /**
     * 菜单路径
     */
    @ExcelProperty(value = "菜单路径")
    private String path;

    /**
     * 权限标识(多个用逗号分隔，如：user:add,user:update)
     */
    @ExcelProperty(value = "权限标识")
    private String permit;

    /**
     * 菜单图标
     */
    @ExcelProperty(value = "菜单图标")
    private String icon;

    /**
     * 排序等级
     */
    @NotNull(message = "排序等级不能为空")
    @ExcelProperty(value = "排序等级")
    private Integer sort;

    /**
     * 显示状态[0-显示 1-隐藏]
     */
    @NotBlank(message = "显示状态不能为空")
    @ExcelProperty(value = "显示状态")
    private String displayName;

    @Override
    public String valid() {
        StringBuilder sb = new StringBuilder();
        String message = super.valid();
        if (StringUtils.isNotBlank(message)) {
            sb.append(message);
        }
        // TODO 根据菜单类型，判断菜单路径、权限标识、菜单图标是否为空
        return sb.toString();
    }
}
